package com.itheima.ticket04;

public class Ticket implements Runnable {
    private int count=100;

    @Override
    public void run() {
        while (true){
            maipiao();
        }
    }

    public synchronized void maipiao(){
        if(count==0){
          return;
        }else {
            try {
                Thread.sleep(100);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            count--;
            System.out.println(Thread.currentThread().getName()+"正在卖票,还剩"+count);
        }
    }
}
